package com.seal.yoyoshop.adminweb;

import com.seal.yoyoshop.bin.User;
import com.seal.yoyoshop.service.UserService;
import com.seal.yoyoshop.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UserDeleteServlet", value = "/admin/userDelete")
public class UserDeleteServlet extends HttpServlet {

    private UserService userService = new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setAttribute("flag",2);

        String idstr = request.getParameter("id");
        int id = Integer.parseInt(idstr);
        User user = userService.getUserById(id);
        user.setStatus(0);
        userService.updateUser(user);

        response.sendRedirect("userList?page=1&size=16");
    }

}
